/*
 * @Description: 
 * @Autor: 商晓彬
 * @Date: 2021-11-29 09:28:18
 * @LastEditors: 商晓彬
 * @LastEditTime: 2022-01-04 14:38:47
 */
import { Component, Injector, ViewChild } from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import { finalize } from 'rxjs/operators';
import { MessageService } from '@abp/message/message.service';
import { LazyLoadEvent } from 'primeng/api';
import { Table } from 'primeng/components/table/table';
import { Paginator } from 'primeng/components/paginator/paginator';
import { ProductionReviewServiceProxy } from '@shared/service-proxies/service-proxies';

@Component({
    selector: 'app-warehouse-review',
    templateUrl: './warehouse-review.component.html',
    styleUrls: ['./warehouse-review.component.less']
})
export class WarehouseReviewComponent extends AppComponentBase {

    constructor(
        injector: Injector,
        private _messageService: MessageService,
        private _productionReviewServiceProxy: ProductionReviewServiceProxy,
    ) {
        super(injector);
    }
    release = undefined;
    certificate = undefined;
    lotNumber = undefined;
    lotName = undefined;
    module = undefined;
    productNum = undefined;
    chooseFlag = false;
    //弹窗
    form = { release: undefined, certificate: undefined };
    releaseOptions = [];
    certificateOptions = [];
    //表格
    warehousingRecord = [];
    warehouseRecord = [];
    assortRecord = [];
    exWarehouseRecord = [];
    rejectRecord = [];
    quarantineRecord = [];
    repairRecord = [];
    scrapRecord = [];
    ngOnInit() {
    }
    getMateralStuts(item) {
        switch (item) {
            case 0:
                return '正常品';
            case 1:
                return '隔离品';
            case 2:
                return '返修品';
            case 3:
                return '报废品';

            default:
                return null;
        }
    }
    resetTop() {
        this.release = undefined;
        this.certificate = undefined;
    }
    resetLower() {
        this.lotNumber = undefined;
        this.lotName = undefined;
        this.module = undefined;
        this.productNum = undefined;
    }
    search() {
        this.form.certificate = undefined;
        this.form.release = undefined;
        this.releaseOptions = [];
        this.certificateOptions = [];
        this.chooseFlag = true;
        //合格证下拉
        this._productionReviewServiceProxy.getQualifiedNumberListForReview(
            this.lotNumber,
            this.lotName,
            this.module,
            this.productNum,
            undefined,
            undefined
        ).pipe(finalize(() => { })).subscribe(result => {
            this.certificateOptions = result;
        });
        //放行单下拉
        this._productionReviewServiceProxy.getReleaseOrderrListForReview(
            this.lotNumber,
            this.lotName,
            this.module,
            this.productNum,
            undefined,
            undefined
        ).pipe(finalize(() => { })).subscribe(result => {
            this.releaseOptions = result;
        });
    }
    onHide(event) {
        //弹窗关闭
        this.form.certificate = undefined;
        this.form.release = undefined;
        this.certificateOptions = [];
        this.releaseOptions = [];
    }
    searchTable() {
        //入库记录
        this._productionReviewServiceProxy.getStorePutRecordListForReview(
            this.form.certificate,
            this.form.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.warehousingRecord = result;
        });
        //库存信息
        this._productionReviewServiceProxy.getStoreInfoListForReview(
            this.form.certificate,
            this.form.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.warehouseRecord = result;
        });
        //配套记录
        this._productionReviewServiceProxy.getPreSuiteListForReview(
            this.form.certificate,
            this.form.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.assortRecord = result;
        });
        //出库记录
        this._productionReviewServiceProxy.getDeliveryOutListForReview(
            this.form.certificate,
            this.form.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.exWarehouseRecord = result;
        });
        //退库记录
        this._productionReviewServiceProxy.getCancellingListForReview(
            this.form.certificate,
            this.form.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.rejectRecord = result;
        });
        //隔离记录
        this._productionReviewServiceProxy.getQuarantineRecordForReview(
            this.form.certificate,
            this.form.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.quarantineRecord = result;
        });
        //返修记录
        this._productionReviewServiceProxy.getReturnRecordForReview(
            this.form.certificate,
            this.form.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.repairRecord = result;
        });
        //报废记录
        this._productionReviewServiceProxy.getScrapRecordForReview(
            this.form.certificate,
            this.form.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.scrapRecord = result;
        });

    }
    getTableList() {
        //入库记录
        this._productionReviewServiceProxy.getStorePutRecordListForReview(
            this.certificate,
            this.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.warehousingRecord = result;
        });
        //库存信息
        this._productionReviewServiceProxy.getStoreInfoListForReview(
            this.certificate,
            this.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.warehouseRecord = result;
        });
        //配套记录
        this._productionReviewServiceProxy.getPreSuiteListForReview(
            this.certificate,
            this.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.assortRecord = result;
        });
        //出库记录
        this._productionReviewServiceProxy.getDeliveryOutListForReview(
            this.certificate,
            this.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.exWarehouseRecord = result;
        });
        //退库记录
        this._productionReviewServiceProxy.getCancellingListForReview(
            this.certificate,
            this.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.rejectRecord = result;
        });
        //隔离记录
        this._productionReviewServiceProxy.getQuarantineRecordForReview(
            this.certificate,
            this.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.quarantineRecord = result;
        });
        //返修记录
        this._productionReviewServiceProxy.getReturnRecordForReview(
            this.certificate,
            this.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.repairRecord = result;
        });
        //报废记录
        this._productionReviewServiceProxy.getScrapRecordForReview(
            this.certificate,
            this.release,
        ).pipe(finalize(() => { })).subscribe(result => {
            this.scrapRecord = result;
        });
    }

}
